package com.winchain.chainbill.bill.biz.send.rx;

import com.shell.bee.base.utils.StringUtil;
import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.winchain.chainbill.bill.base.po.CbRec;
import com.winchain.chainbill.bill.biz.Bill;
import com.winchain.chainbill.bill.biz.BillEvent;
import com.winchain.chainbill.bill.biz.send.service.BillHoldService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BillHldrSubscriber extends OnErrorNotImplementedSubscriber<BillEvent<? extends Object>> {
	private final Log logger = LogFactory.getLog(getClass());
	@Autowired
	private BillHoldService billHoldService;

	public void onApplicationEvent(BillEvent<? extends Object> t) {
		CbRec bill = t.getBill().getRec();

		String ownerId = (String) t.getValue("OwnerId");
		if (StringUtil.emptyAndNull(ownerId)) {
			this.logger.warn("warnning:ownerId ����!");
			return;
		}
		this.billHoldService.own(bill, ownerId);
	}
}
